<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
    <title>App</title>
    <style>
        /* 简单的模态框样式 */
        .buttonc {
            height: 100px;
            text-align: center;
            width: 200px;
        }

        .modal {
            display: none;
            /* 默认隐藏 */
            position: fixed;
            /* 固定定位 */
            z-index: 1;
            /* 置于顶层 */
            left: 0;
            top: 0;
            width: 100%;
            /* 宽度占满屏幕 */
            height: 100%;
            /* 高度占满屏幕 */
            overflow: auto;
            /* 如果需要的话，可以滚动 */
            background-color: rgb(0, 0, 0);
            /* 背景色 */
            background-color: rgba(0, 0, 0, 0.4);
            /* 黑色背景，带有透明度 */
        }

        .modal-content {
            background-color: #fefefe;
            margin: 35% auto;
            /* 15% 从顶部和 50% 从左右两边 */
            padding: 20px;
            border: 1px solid #888;
            width: 80%;
            /* 宽度 */
        }

        .close {
            color: #aaa;
            float: right;
            font-size: 28px;
            font-weight: bold;
        }

        .close:hover,
        .close:focus {
            color: black;
            text-decoration: none;
            cursor: pointer;
        }


        body {
            width: 100%;
            height: 100%;
            background: #FFFFFF;
        }

        .bg {
            display: none;
            position: fixed;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            z-index: 10;
            background: rgba(0, 0, 0, 0.9);
            text-align: end;
            overflow: hidden;
            padding: 1rem 5px 0 1rem;
        }

        .bg img {
            width: 93%;
            height: auto;
        }
    </style>
</head>

<body>
    <div id="myModal" class="modal">
        <div class="modal-content">
            <span class="close">&times;</span>
            <p style="font-size: 36px;">为了更好的体验，我们建议您下载我们的App。</p>
            <button id="downloadBtn" class="buttonc">下载APP</button>
        </div>
    </div>
    <div class="app">
        <div class="bg"><img src="https://mxlykj.com:8009/mtz/hintH5.png" alt="">
        </div>
    </div>


    <script>
        document.getElementById('downloadBtn').addEventListener('click', function () {
            var u = navigator.userAgent;
            var isAndroid = /android/i.test(u);
            var isiOS = /iPad|iPhone|iPod/.test(u) && !window.MSStream;

            if (isiOS) {
                window.location.href = 'https://apps.apple.com/cn/app/你的app store跳转路径';
            } else if (isAndroid) {
                window.location.href = 'app安装包路径';
            } else {
                alert('不支持的设备类型');
            }
        });
        window.onload = function () {
            if (isWeixin()) {
                $(".bg").css('display', 'block')


            } else {
                var modal = document.getElementById("myModal");
                modal.style.display = "block";

                var span = document.getElementsByClassName("close")[0];
                span.onclick = function () {
                    modal.style.display = "none";
                }
                window.onclick = function (event) {
                    if (event.target == modal) {
                        modal.style.display = "none";
                    }
                }
            }


        }

        function isWeixin() {
            var ua = navigator.userAgent.toLowerCase();
            if (ua.match(/MicroMessenger/i) == "micromessenger") {
                return true;
            } else {
                return false;
            }
        }

    </script>
</body>

</html>